<?php 

/**
 * CodeRS - Atviras kodas Lietuvai
 * Copyright (C) 2007 CodeRS www.coders.lt info@coders.lt
 * MightMedia TVS
 * straipsniai.php - Straipsnių administravimas
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 * 
 * 
 * Ši programa yra laisva. Jūs galite ją platinti ir/arba modifikuoti
 * remdamiesi Free Software Foundation paskelbtomis GNU Bendrosios
 * Viešosios licencijos sąlygomis: 2 licencijos versija, arba (savo
 * nuožiūra) bet kuria vėlesne versija.
 * 
 * Ši programa platinama su viltimi, kad ji bus naudinga, bet BE JOKIOS
 * GARANTIJOS; be jokios numanomos PERKAMUMO ar TINKAMUMO KONKRETIEMS
 * TIKSLAMS garantijos. Žiūrėkite GNU Bendrąją Viešąją licenciją norėdami
 * sužinoti smulkmenas.
 * 
 * Jūs turėjote kartu su šia programa gauti ir GNU Bendrosios Viešosios
 * licencijos kopija; jei ne - rašykite Free Software Foundation, Inc., 59
 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**/

if ($_SERVER['PHP_SELF'] == __FILE__) { header('location: ?'); exit(); }
if (!defined("LEVEL") || LEVEL < 30 || !defined("OK")) { header('location: ?home'); }
?>
		<h2>Straipsnių administravimas</h2>
		<?php
		/* #######################################
		########### Straipsniu Funkcijos #########
		##########################################*/

		// Redagavimas
		if (isset($_POST['s_t_edit']) && $_POST['s_t_edit'] == 'Redaguoti') {
			$straipsnis = (int)$_POST['s_tema'];
			$sql = mysql_fetch_assoc($db->uzklausa("SELECT * FROM s_temos WHERE id=$straipsnis"));
			$text = "
				<table border=0 width=100%>
					<tr>
						<td>
							<form name=\"s_t_edit\" action=\"?id,46;a,4\" method=\"post\">
								<input name=\"s_t_id\" type=\"hidden\" value=" . $sql['id'] .">
								<input name=\"s_t_edit_text\" type=\"text\" value=" . $sql['pav'] .">
								<input name='s_t_edit' type=\"submit\" value=\"Keisti\">
							</form>
						</td>
					</tr>
				</table>
			";
			lentele("Veiksmai", $text);
			unset($text,$sql,$straipsnis);
		}
		// Keiciamas temos pavadinimas. Redagavimas 2
		if (isset($_POST['s_t_edit']) && $_POST['s_t_edit'] == 'Keisti') {
			$keisti = input($_POST['s_t_edit_text']);
			$id = (int)$_POST['s_t_id'];
			$db->uzklausa("UPDATE s_temos SET pav='" . $keisti ."' WHERE id=$id") or die(mysql_error());
			header("Location: ?id,46;a,4");
		}
		// Naujos temos sukurimas
		if (isset($_POST['s_t_create']) && $_POST['s_t_create'] == 'Sukurti') {
			$text = "
				<form name=\"s_t_sukurimas\" action=\"?id,46;a,4\" method=\"post\">
					<input name=\"s_t_text\" type=\"text\" value=\"\">
					<input name=\"s_t_sukurimas\" type=\"submit\" value=\"Sukurti\">
				</form>
			";
			lentele("Veiksmai",$text);
			unset($text);
		}
		// Naujos temos ikelima si DB
		if (isset($_POST['s_t_sukurimas']) && $_POST['s_t_sukurimas'] == 'Sukurti') {
			$pav = input($_POST['s_t_text']);
			$db->uzklausa("INSERT INTO s_temos (pav) VALUES ('" . $pav ."')");
			header("Location: ?id,46;a,4");
			unset($pav);
		}
		// Temos istrynimas
		if (isset($_POST['s_t_delete']) && $_POST['s_t_delete'] == 'Trinti') {
			$id = (int)$_POST['s_tema'];
			$punktai = $db->uzklausa("SELECT id FROM s_punktai WHERE sid='" . $id ."'");
			while ($row = mysql_fetch_assoc($punktai)) {
				$straips = $db->uzklausa("SELECT id FROM straipsniai WHERE pid='" . $row['id'] ."'");
				while ($row2 = mysql_fetch_assoc($straips)) {
					$db->uzklausa("DELETE FROM s_kom WHERE sid='" . $row2['id'] ."'");
				}
			}
			$db->uzklausa("DELETE FROM s_temos WHERE id='" . $id ."'");
			unset($row,$row2,$punktai,$straips,$id);
			header("Location: ?id,46;a,4");
		}
		// Potemes sukurimas
		if (isset($_POST['s_po_create']) && $_POST['s_po_create'] == 'Sukurti') {
			$text = "
				<form name=\"s_p_sukurimas\" action=\"?id,46;a,4\" method=\"post\">
						<input name=\"s_p_id\" type=\"hidden\" value=" . $_POST['s_temos'] .">
                		<input name=\"s_p_poteme\" type=\"text\" value=\"\">
                		<input name=\"s_p_sukurimas\" type=\"submit\" value=\"Sukurti\">
				</form>
			";
			lentele("Potemės sukūrimas",$text);
			unset($text);
		}
		// Potemes sukurimas pagal pasirinkta Tema
		if (isset($_POST['s_p_sukurimas']) && $_POST['s_p_sukurimas'] == 'Sukurti') {
			$id = (int)$_POST['s_p_id'];
			$pav = input($_POST['s_p_poteme']);
			$db->uzklausa("INSERT INTO s_punktai (sid,pav) VALUES ('" . $id ."', '" . $pav ."')");
			unset($id,$pav);
			header("Location: ?id,46;a,4");
		}
		// Potemes pirmas etepas pakeisti teksta
		if (isset($_POST['s_po_edit']) && $_POST['s_po_edit'] == 'Redaguoti') {
			$id = (int)$_POST['s_po_poteme_id'];
			$sql = mysql_fetch_assoc($db->uzklausa("SELECT pav FROM s_punktai WHERE id='" . $id ."'"));
			$text = "
				<form name=\"s_po_c\" action=\"\" method=\"post\">
					<input name=\"s_po_pav\" type=\"text\" value=" . $sql['pav'] .">
					<input name=\"s_po_id\" type=\"hidden\" value=" . $id .">
                	<input name=\"s_po_red\" type=\"submit\" value=\"Pakeisti\">
				</form>
			";
			lentele("Potemės redagavimas",$text);
			unset($text,$sql,$id);
		}
		//POtemes antras etapas pakeiciantis Potemes pavadinima
		if (isset($_POST['s_po_red']) && $_POST['s_po_red'] == 'Pakeisti') {
			$id = (int)$_POST['s_po_id'];
			$pav = input($_POST['s_po_pav']);
			$db->uzklausa("UPDATE s_punktai SET pav='" . $pav ."' WHERE id='" . $id . "'");
			unset($id,$pav);
			header("Location: ?id,46;a,4");
		}
		// Potemiu trynimas su visais komentarais
		if (isset($_POST['s_po_delete']) && $_POST['s_po_delete'] == 'Trinti') {
			$id = (int)$_POST['s_po_poteme_id'];
			$sql = mysql_fetch_assoc($db->uzklausa("SELECT id, pid, autorius_id FROM straipsniai WHERE pid='" . $id ."'"));
			/*while ($row = mysql_fetch_assoc($sql)) {
				$db->uzklausa("DELETE FROM s_kom WHERE sid='" . $row['id'] ."'");
				$db->uzklausa("DELETE FROM straipsniai WHERE id='" . $row['id'] ."'");
			}*/
			$db->uzklausa("DELETE FROM s_kom WHERE sid=" . escape($row['pid']) ."");
			$db->uzklausa("DELETE FROM s_punktai WHERE id='" . $id ."'");
			$db->uzklausa("UPDATE users SET taskai=taskai-6 WHERE id='" . $row['autorius_id'] ."'");
			unset($id,$sql,$row);
			header("Location: ?id,46;a,4");
		}
		// Issaugo pakeista straipsni
		if (isset($_POST['s_s_redagavimas']) && $_POST['s_s_redagavimas'] == 'Išsaugoti') {
			$straipsnis = $_POST['s_s_edit_full'];
			$id = $_POST['s_s_id'];
			$db->uzklausa("UPDATE straipsniai SET f_text='" . $straipsnis ."' WHERE id='" . $id ."'");
			unset($id,$straipsnis);
			header("Location: ?id,46;a,4");
		}
		// Issaugoti pakeista Straipsni BET issaugom NEAKTYVUOTA straipsni
		if (isset($_POST['s_s_a_save']) && $_POST['s_s_a_save'] == 'Išsaugoti') {
			$straipsnis = $_POST['s_s_a_edit_full'];
			$id = $_POST['s_s_a_edit_id'];
			$db->uzklausa("UPDATE straipsniai SET f_text='" . $straipsnis ."' WHERE id='" . $id ."'");
			unset($id,$straipsnis);
			header("Location: ?id,46;a,4");
		}
		// Pasirinkto Straipsnio trynimas
		if (isset($_POST['s_s_del']) && $_POST['s_s_del'] == 'Trinti') {
			$id = (int)$_POST['s_s_straip'];
			$db->uzklausa("DELETE FROM straipsniai WHERE id='" . $id ."'");
			$db->uzklausa("DELETE FROM s_kom WHERE sid='" . $id ."'");
			unset($id);
			header("Location: ?id,46;a,4");
		}
		// Aktyvuojamas straipsnis
		if (isset($_POST['s_s_a_aktyvuoti']) && $_POST['s_s_a_aktyvuoti'] == 'Aktyvuoti') {
			$id = (int)$_POST['s_s_a_id'];
			$db->uzklausa("UPDATE straipsniai SET rodoma='TAIP' WHERE id='" . $id ."'");
			$db->uzklausa("UPDATE users SET taskai=taskai+5 WHERE id=".escape($_POST['autorius'])."");
			unset($id);
			header("Location: ?id,46;a,4");
		}
		// Ištrinti neaktyvuota straipsni
		if (isset($_POST['s_s_a_trinti']) && $_POST['s_s_a_trinti'] == 'Ištrinti') {
			$id = (int)$_POST['s_s_a_id'];
			$db->uzklausa("DELETE FROM straipsniai WHERE id='" . $id ."'");
			$db->uzklausa("DELETE FROM s_kom WHERE sid='" . $id ."'");
			unset($id);
			header("Location: ?id,46;a,4");
		}
		// Naujo straipsnio sukurimas
		if (isset($_POST['s_s_n_save']) && $_POST['s_s_n_save'] == 'Išsaugoti') {
			$straipsnis = $_POST['s_s_n_edit_full'];
			$s_small = $_POST['s_s_n_edit_smaill'];
			$nick = $_SESSION['username'];
			$nick_id = $_SESSION['id'];
			$tema = $_POST['s_s_n_tema'];
			$date = date("Y-m-d H:i:s");
			$pav = $_POST['s_s_n_pav'];
			if (!empty($straipsnis) && !empty($s_small)) {
				$db->uzklausa("INSERT INTO straipsniai (pid, pav, t_text, f_text, date, autorius, autorius_id) VALUES (
							'" . $tema ."', '" . $pav ."', '" . $s_small ."', '" . $straipsnis ."', '" . $date ."', '" . $nick ."', '" . $nick_id ."')");
				unset($straipsnis,$s_small,$nick,$nick_id,$tema,$date);
				header("Location: ?id,46;a,4");

			}
		}
		// Temu pateikimas redagavimui
		echo "
		<table width=100%>
			<tr>
				<td valign='top'>";
					$text = "<form name=\"s_tema\" action=\"?id,46;a,4\" method=\"post\">
						<select size=\"1\" name=\"s_tema\">";
						    $sql = $db->uzklausa("SELECT * FROM s_temos");
						    while($row = mysql_fetch_assoc($sql)) {
						    	$text .= "<option value=" . $row['id'] .">" . $row['pav'] ."</option>";
						    }
						$text .="
						</select>
						<br /><br />
						<input name=\"s_t_edit\" type=\"submit\" value=\"Redaguoti\">
						<input name=\"s_t_create\" type=\"submit\" value=\"Sukurti\">
						<input name=\"s_t_delete\" type=\"submit\" value=\"Trinti\">
					</form>";
					lentele("Temos sukūrimas",$text);
					unset($text,$sql,$row);

					// Potemiu Pateikimas administravimui
					echo "
				</td>
				<td valign='top'>";
					$text = "
					<form name=\"s_poteme\" action=\"?id,46;a,4\" method=\"post\">
					<fieldset>
					<legend>Potemių redagavimas</legend>
								<select size=\"1\" name=\"s_po_poteme_id\">";
						    	$sql = $db->uzklausa("SELECT * FROM s_temos");
						    	while($row = mysql_fetch_assoc($sql)) {
						    		$text .= "<option value=" . $row['id'] ." disabled>" . $row['pav'] ."</option>\n";
						    		$sql2 = $db->uzklausa("SELECT * FROM s_punktai WHERE sid='" . $row['id'] ."'");
						    		while ($row2 = mysql_fetch_assoc($sql2)) {
						    				$text .= "<option value='" . $row2['id'] ."'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $row2['pav'] ."</option>\n";
						    		}
						    	}
								$text .="
								</select>
								<input name='s_po_edit' type=\"submit\" value=\"Redaguoti\">
								<input name='s_po_delete' type=\"submit\" value=\"Trinti\">
							 </fieldset>
							 </form>
							 <form name=\"s_poteme_c\" action=\"?id,46;a,4\" method=\"post\">
							 <fieldset>
							<legend>Naujos potemės sukūrimas</legend>
							 		<select size=\"1\" name=\"s_temos\">";
						    		$sql = $db->uzklausa("SELECT * FROM s_temos");
						   			 while($row = mysql_fetch_assoc($sql)) {
						    			$text .= "<option value=" . $row['id'] .">" . $row['pav'] ."</option>";
						    		 }
						             $text .="
						             </select>
						             <input name='s_po_create' type=\"submit\" value=\"Sukurti\">
							  </fieldset>
							  </form>";
							 lentele("Potemės", $text);
							 unset($sql2,$sql,$row2,$row,$text);
				// Straipsniu sukurimas, redagavimas, ikelimas
				echo "
				</td>
				<td valign='top'>";
					$text = "
					<form name=\"s_straips_sort\" action=\"?id,46;a,4\" method=\"post\">
					<fieldset><legend>Rodyti tik:</legend>
						 <select size=\"1\" name=\"s_s_sortas\">";
						 		$sql = $db->uzklausa("SELECT * FROM s_temos");
						    	while($row = mysql_fetch_assoc($sql)) {
						    		$text .= "<option value=" . $row['id'] ." disabled>" . $row['pav'] ."</option>";
						    		$sql2 = $db->uzklausa("SELECT * FROM s_punktai WHERE sid='" . $row['id'] ."'");
						    		while ($row2 = mysql_fetch_assoc($sql2)) {
						    			if ($row2['sid'] == $row['id']) {
						    				$text .= "<option value=" . $row2['id'] .">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $row2['pav'] ."</option>";
						    			}
						    		}
						    	}
								unset($sql,$sql2,$row2,$row);
								$text .="
						 </select>
						 <input name='s_s_sort' type=\"submit\" value=\"Tik\">
						 <input name='no_sort' type=\"submit\" value=\"Viską\">
					</fieldset>
					</form>
					";
					// Rusiamas pagal atitinkama poteme
				    if (isset($_POST['s_s_sort']) && $_POST['s_s_sort'] == 'Tik') {
				    	$id = (int)$_POST['s_s_sortas'];
				    	$text .= "<form name=\"s_t_edit_sort\" action=\"?id,46;a,4\" method=\"post\">
						<fieldset><legend>Rodomi tik filtruoti straipsniai:</legend>
						<select size=\"1\" name=\"s_s_straip\">";
						$sql = $db->uzklausa("SELECT id, pav FROM straipsniai WHERE pid='" . $id ."' AND rodoma='TAIP'");
						while($row = mysql_fetch_assoc($sql)) {
							$text .= "<option value=" . $row['id'] ."> " . $row['pav'] ."</option>";
						}
					}
					// Jei nepasirinktas rusiavimas rodomi visi straipsniai
					else {
						$text .= "
						<form name=\"s_t_edit_no_sort\" action=\"?id,46;a,4\" method=\"post\">
						<fieldset>
						<legend>Straipsnių sarašas:</legend>
						<select size=\"1\" name=\"s_s_straip\">";
						$sql = $db->uzklausa("SELECT * FROM s_temos");
						$sql3 = $db->uzklausa("SELECT id, pav, pid FROM straipsniai WHERE rodoma='TAIP'");
						while($row = mysql_fetch_assoc($sql)) {
							$text .= "<option value=" . $row['id'] ." disabled>" . $row['pav'] ."</option>";
							$sql2 = $db->uzklausa("SELECT * FROM s_punktai WHERE sid='" . $row['id'] ."'");
							while ($row2 = mysql_fetch_assoc($sql2)) {
						 			$text .= "<option value=" . $row2['id'] ." disabled>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $row2['pav'] ."</option>";
						 			$sql3 = $db->uzklausa("SELECT id, pav, pid FROM straipsniai WHERE rodoma='TAIP' AND pid='" . $row2['id'] ."'");
						 			while ($row3 = mysql_fetch_assoc($sql3)) {
						 					$text .= "<option value=" . $row3['id'] .">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $row3['pav'] ."</option>";
						 			}
							}
						}
					}
						$text .= "
						</select>
						<input name=\"s_s_red\" type=\"submit\" value=\"Redaguoti\">
						<input name=\"s_s_del\" type=\"submit\" value=\"Trinti\">
						</fieldset>
						<fieldset><legend>Neaktyvūs straipsniai:</legend>
                        <select size=\"1\" name=\"s_s_nerodoma\">";
						$sql = $db->uzklausa("SELECT * FROM s_temos");
						while($row = mysql_fetch_assoc($sql)) {
							$text .= "<option value=" . $row['id'] ." disabled>" . $row['pav'] ."</option>";
							$sql2 = $db->uzklausa("SELECT * FROM s_punktai WHERE sid='" . $row['id'] ."'");
							while ($row2 = mysql_fetch_assoc($sql2)) {
						 			$text .= "<option value=" . $row2['id'] ." disabled>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $row2['pav'] ."</option>";
						 			$sql3 = $db->uzklausa("SELECT id, pav, pid FROM straipsniai WHERE rodoma='NE' AND pid='" . $row2['id'] ."'");
						 			while ($row3 = mysql_fetch_assoc($sql3)) {
						 					$text .= "<option value=" . $row3['id'] .">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $row3['pav'] ."</option>";
						 			}
							}
						}
						$text .= "
						</select>
						<input name=\"s_s_watch\" type=\"submit\" value=\"Peržiūrėti\">
						</fieldset>
						<fieldset>
						<legend>Naujo straipsnio sukūrimas:</legend>
						<input name=\"s_s_create\" type=\"submit\" value=\"Naujas Straipsnis\">
					</fieldset>
					</form>
					";
					lentele("Straipsnių administravimas", $text);
					unset($sql,$sql2,$sql3,$row,$row2,$row3,$text);
					echo "
				</td>
			</tr>
		</table>
		";
		// Naujo straipsnio sukurimas
		if (isset($_POST['s_s_create']) && $_POST['s_s_create'] == 'Naujas Straipsnis') {
			$text .= "
				<table border=0 width=100%>
					<tr>
						<td>
							<fieldset>
							<legend>BBCode</legend>"
							. bbk("s_s_n_edit_full") ."<br>
							<input value=\"Puslapis\" class=\"button\" onclick=\"addText('s_s_n_edit_full', '<--- Puslapis', ' --->');\" type=\"button\">
							</fieldset>
						</td>
					</tr>
					<tr>
						<td colspan=2>
							<form name=\"s_s_n_edit_full\" action=\"?id,46;a,4\" method=\"post\">
							<table border=0 witdh=100%>
								<tr>
									<td width=20%>Pasirinkite potemę:</td>
									<td><select size=\"1\" name=\"s_s_n_tema\">";
									$sql = $db->uzklausa("SELECT * FROM s_temos");
						    		while($row = mysql_fetch_assoc($sql)) {
						    			$text .= "<option value=" . $row['id'] ." disabled>" . $row['pav'] ."</option>";
						    			$sql2 = $db->uzklausa("SELECT * FROM s_punktai WHERE sid='" . $row['id'] ."'");
						    			while ($row2 = mysql_fetch_assoc($sql2)) {
						    				if ($row2['sid'] == $row['id']) {
						    					$text .= "<option value=" . $row2['id'] .">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $row2['pav'] ."</option>";
						    				}
						    			}
						    		}
									unset($sql,$sql2,$row2,$row);
									$text .= "
										</select></td>
								</tr>
								<tr>
									<td>Straipsnio pavadinimas:</td>
									<td><input name=\"s_s_n_pav\" size=100 type=\"text\" value=\"\"></td>
								</tr>
								<tr>
									<td valign='top'>Trumpas aprašymas:</td>
									<td><textarea name=\"s_s_n_edit_smaill\" rows=4 cols=50 wrap=\"on\"></textarea></td>
								</tr>
								<tr>
									<td valign='top'>Straipsnis:</td>
									<td><textarea name=\"s_s_n_edit_full\" rows=20 cols=70 wrap=\"on\"></textarea></td>
								</tr>
							</table>
								<input name=\"s_s_n_save\" type=\"submit\" value=\"Išsaugoti\">
								<input name=\"s_s_n_rodyti\" type=\"submit\" value=\"Peržiūrėti\">
							</form>
						</td>
					</tr>
				</table>
			";
			lentele("Naujo straipsnio sukūrimas",$text);
			unset($text);
		}
		// Naujo straipsnio perziure
		if (isset($_POST['s_s_n_rodyti']) && $_POST['s_s_n_rodyti'] == 'Peržiūrėti') {
			$txt = $_POST['s_s_n_edit_full'];
			$pav = $_POST['s_s_n_pav'];
			$s_small = $_POST['s_s_n_edit_smaill'];
			$text .= "
				<table border=0 width=100%>
					<tr>
						<td>
							<fieldset>
							<legend>BBCode</legend>"
							. bbk("s_s_n_edit_full") ."<br>
							<input value=\"Puslapis\" class=\"button\" onclick=\"addText('s_s_n_edit_full', '<--- Puslapis', ' --->');\" type=\"button\">
							</fieldset>
						</td>
					</tr>
					<tr>
						<td colspan=2>
							<form name=\"s_s_n_edit_full\" action=\"?id,46;a,4\" method=\"post\">
							<table border=0 witdh=100%>
								<tr>
									<td width=20%>Pasirinkite potemę:</td>
									<td><select size=\"1\" name=\"s_s_n_tema\">";
									$sql = $db->uzklausa("SELECT * FROM s_temos");
						    		while($row = mysql_fetch_assoc($sql)) {
						    			$text .= "<option value=" . $row['id'] ." disabled>" . $row['pav'] ."</option>";
						    			$sql2 = $db->uzklausa("SELECT * FROM s_punktai WHERE sid='" . $row['id'] ."'");
						    			while ($row2 = mysql_fetch_assoc($sql2)) {
						    				if ($row2['sid'] == $row['id']) {
						    					$text .= "<option value=" . $row2['id'] .">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $row2['pav'] ."</option>";
						    				}
						    			}
						    		}
									unset($sql,$sql2,$row2,$row);
									$text .= "
										</select></td>
								</tr>
								<tr>
									<td>Straipsnio pavadinimas:</td>
									<td><input name=\"s_s_n_pav\" size=100 type=\"text\" value=" . $pav ."></td>
								</tr>
								<tr>
									<td valign='top'>Trumpas aprašymas:</td>
									<td><textarea name=\"s_s_n_edit_smaill\" rows=4 cols=50 wrap=\"on\">$s_small</textarea></td>
								</tr>
								<tr>
									<td valign='top'>Straipsnis:</td>
									<td><textarea name=\"s_s_n_edit_full\" rows=20 cols=70 wrap=\"on\">$txt</textarea></td>
								</tr>
							</table>
								<input name=\"s_s_n_save\" type=\"submit\" value=\"Išsaugoti\">
								<input name=\"s_s_n_rodyti\" type=\"submit\" value=\"Peržiūrėti\">
							</form>
						</td>
					</tr>
				</table>
			";
			lentele("Naujo straipsnio sukūrimas",$text);
			unset($text);
			$text = "" . bbcode($txt) ."";
			lentele("Peržiūra",$text);
			unset($text);

		}
		// Perziureti pasirinkta straipsni
		if (isset($_POST['s_s_watch']) && $_POST['s_s_watch'] == 'Peržiūrėti') {
			$id = (int)$_POST['s_s_nerodoma'];
			$sql = mysql_fetch_assoc($db->uzklausa("SELECT * FROM straipsniai WHERE id='" . $id ."'"));
			$text = "
				<table border=0 width=100%>
					<tr>
						<td width=20%>
							<fieldset>
							<legend>Informacija</legend>
							Autorius: <a href='?id,47;m," . $sql['autorius_id'] ."'>" . $sql['autorius'] ."</a> <a href='?id,45;n,1;u," . $sql['autorius'] ."'><img src='images/pm/mail.png' border=0></img></a><br>
							Data: " . $sql['date'] ."<br>
							</fieldset>
						</td>
						<td>
							<fieldset>
							<legend>BBCode</legend>"
							. bbk("s_s_a_edit_full") ."
							</fieldset>
						</td>
					</tr>
					<tr>
						<td colspan=2>
							<form name=\"s_s_a_edit_full\" action=\"?id,46;a,4\" method=\"post\">
								<textarea name=\"s_s_a_edit_full\" rows=20 cols=100 wrap=\"on\">" . $sql['f_text'] ."</textarea><br>
								<input name=\"s_s_a_id\" type=\"hidden\" value=" . $id ." />
								<input name=\"s_s_a_save\" type=\"submit\" value=\"Išsaugoti\" />
								<input name=\"s_s_a_rodyti\" type=\"submit\" value=\"Peržiūrėti\" />
								<input name=\"s_s_a_aktyvuoti\" type=\"submit\" value=\"Aktyvuoti\" />
								<input name=\"autorius\" type=\"hidden\" value=\"" . $sql['autorius_id'] ."\" />
								<input name=\"s_s_a_trinti\" type=\"submit\" value=\"Ištrinti\" />
							</form>
						</td>
					</tr>
				</table>
			";
			lentele("Neaktyvuoto straipsnio administravimas", $text);
			unset($text,$sql,$id);
		}
		//Perziureti pasirinkta neaktyvuota straipsni
		if (isset($_POST['s_s_a_rodyti']) && $_POST['s_s_a_rodyti'] == 'Peržiūrėti') {
			$id = (int)$_POST['s_s_a_id'];
			$txt = $_POST['s_s_a_edit_full'];
			$sql = mysql_fetch_assoc($db->uzklausa("SELECT * FROM straipsniai WHERE id='" . $id ."'"));
			$text = "
				<table border=0 width=100%>
					<tr>
						<td width=20%>
							<fieldset>
							<legend>Informacija</legend>
							Autorius: <a href='?id,47;m," . $sql['autorius_id'] ."'>" . $sql['autorius'] ."</a> <a href='?id,45;n,1;u," . $sql['autorius'] ."'><img src='images/pm/mail.png' border=0></img></a><br>
							Data: " . $sql['date'] ."<br>
							</fieldset>
						</td>
						<td>
							<fieldset>
							<legend>BBCode</legend>"
							. bbk("s_s_edit_full") ."
							</fieldset>
						</td>
					</tr>
					<tr>
						<td colspan=2>
							<form name=\"s_s_a_edit_full\" action=\"?id,46;a,4\" method=\"post\">
								<textarea name=\"s_s_a_edit_full\" rows=20 cols=100 wrap=\"on\">" . $txt ."</textarea><br>
								<input name=\"s_s_a_id\" type=\"hidden\" value=" . $id .">
								<input name=\"s_s_a_save\" type=\"submit\" value=\"Išsaugoti\">
								<input name=\"s_s_a_rodyti\" type=\"submit\" value=\"Peržiūrėti\">
								<input name=\"s_s_a_aktyvuoti\" type=\"submit\" value=\"Aktyvuoti\">
								<input name=\"autorius\" type=\"hidden\" value=\"" . $sql['autorius_id'] ."\" />
								<input name=\"s_s_a_trinti\" type=\"submit\" value=\"Ištrinti\">
							</form>
						</td>
					</tr>
				</table>
			";
			lentele("Straipsnio redagavimas", $text);
			unset($text);
			$text = "" . bbcode($txt) ."";
			lentele("Peržiūra",$text);
			unset($text,$sql,$id);
   		}
		// Straipsnio redagavimo lentele
		if (isset($_POST['s_s_red']) && $_POST['s_s_red'] == 'Redaguoti') {
			$id = (int)$_POST['s_s_straip'];
			$sql = mysql_fetch_assoc($db->uzklausa("SELECT * FROM straipsniai WHERE id='" . $id ."'"));
			$text = "
				<table border=0 width=100%>
					<tr>
						<td width=20%>
							<fieldset>
							<legend>Informacija</legend>
							Autorius: <a href='?id,47;m," . $sql['autorius_id'] ."'>" . $sql['autorius'] ."</a> <a href='?id,45;n,1;u," . $sql['autorius'] ."'><img src='images/pm/mail.png' border=0></img></a><br>
							Data: " . $sql['date'] ."<br>
							</fieldset>
						</td>
						<td>
							<fieldset>
							<legend>BBCode</legend>"
							. bbk("s_s_edit_full") ."
							</fieldset>
						</td>
					</tr>
					<tr>
						<td colspan=2>
							<form name=\"s_s_edit_full\" action=\"?id,46;a,4\" method=\"post\">
								<textarea name=\"s_s_edit_full\" rows=20 cols=100 wrap=\"on\">" . $sql['f_text'] ."</textarea><br>
								<input name=\"s_s_id\" type=\"hidden\" value=" . $id .">
								<input name=\"s_s_redagavimas\" type=\"submit\" value=\"Išsaugoti\">
								<input name=\"s_s_rodyti\" type=\"submit\" value=\"Peržiūrėti\">
							</form>
						</td>
					</tr>
				</table>
			";
			lentele("Straipsnio redagavimas", $text);
			unset($text,$sql,$id);
		}
		// Jei norima perziureti straipsni
		if (isset($_POST['s_s_rodyti']) && $_POST['s_s_rodyti'] == 'Peržiūrėti') {
			$id = (int)$_POST['s_s_id'];
			$txt = $_POST['s_s_edit_full'];
			$sql = mysql_fetch_assoc($db->uzklausa("SELECT * FROM straipsniai WHERE id='" . $id ."'"));
			$text = "
				<table border=0 width=100%>
					<tr>
						<td width=20%>
							<fieldset>
							<legend>Informacija</legend>
							Autorius: <a href='?id,47;m," . $sql['autorius_id'] ."'>" . $sql['autorius'] ."</a> <a href='?id,45;n,1;u," . $sql['autorius'] ."'><img src='images/pm/mail.png' border=0></img></a><br>
							Data: " . $sql['date'] ."<br>
							</fieldset>
						</td>
						<td>
							<fieldset>
							<legend>BBCode</legend>"
							. bbk("s_s_edit_full") ."
							</fieldset>
						</td>
					</tr>
					<tr>
						<td colspan=2>
							<form name=\"s_s_edit_full\" action=\"?id,46;a,4\" method=\"post\">
								<textarea name=\"s_s_edit_full\" rows=20 cols=100 wrap=\"on\">" . $txt ."</textarea><br>
								<input name=\"s_s_redagavimas\" type=\"submit\" value=\"Išsaugoti\">
								<input name=\"s_s_rodyti\" type=\"submit\" value=\"Peržiūrėti\">
								<input name=\"s_s_id\" type=\"hidden\" value=" . $id .">
							</form>
						</td>
					</tr>
				</table>
			";
			lentele("Straipsnio redagavimas", $text);
			unset($text,$sql);
			$text = "" . bbcode($txt) ."";
			lentele("Peržiūra",$text);
			unset($xt,$id);
		}

		?>
	</div>
	</div>